<template>
  <div class="app-container">

    <el-tabs v-model="activeName">
      <el-tab-pane label="价格配置" name="first">

        <el-form size="medium" label-width="100px">
          <el-row :gutter="20" style="margin-bottom: 12px">
            <el-col :sm="24" :md="12" :lg="12">
              <el-card class="box-card" body-style="height:220px">
                <MmvTitle title="押金设置"></MmvTitle>
                <div class="card-item table-padding">
                  <span>违章押金</span>
                  <el-input v-model="form.tenantConfig.illegalAmount" @keyup.native="
                form.tenantConfig.illegalAmount = oninput(
                  form.tenantConfig.illegalAmount,
                  2
                )
              "></el-input>
                  <span>元</span>
                </div>
                <div class="card-item table-padding">
                  车辆押金预授权有效期
                  <el-input v-model="form.tenantConfig.depositPreAuthorization" @keyup.native="
                form.tenantConfig.depositPreAuthorization = oninput(
                  form.tenantConfig.depositPreAuthorization,
                  0
                )
              "></el-input>
                  天
                </div>
                <div class="card-item table-padding">
                  违章押金预授权有效期
                  <el-input v-model="form.tenantConfig.illegalDepositAuthorization" @keyup.native="
                form.tenantConfig.illegalDepositAuthorization = oninput(
                  form.tenantConfig.illegalDepositAuthorization,
                  0
                )
              "></el-input>
                  天
                </div>
              </el-card>
            </el-col>
            <el-col :sm="24" :md="12" :lg="12">
              <el-card class="box-card" body-style="height:220px">
                <MmvTitle title="支付规则"></MmvTitle>
                <div class="card-item table-padding">
                  <el-form-item label="下单延迟时间" prop="delayTime">
                    <el-input v-model="form.tenantConfig.delayTime"  @keyup.native="form.tenantConfig.delayTime = oninput(form.tenantConfig.delayTime,0)" placeholder="请输入" clearable
                              :style="{ 'min-width': '200px' }">
                      <template slot="append">小时</template>
                    </el-input>
                  </el-form-item>
                  <el-form-item label="免费时长" prop="freeHour">
                    <el-input v-model="form.tenantConfig.freeHour" @keyup.native="form.tenantConfig.freeHour = oninput(form.tenantConfig.freeHour,0)"  placeholder="请输入" clearable
                              :style="{ 'min-width': '200px' }">
                      <template slot="append">小时</template>
                    </el-input>
                  </el-form-item>
                </div>
              </el-card>
            </el-col>
          </el-row>

          <el-row :gutter="20" style="margin-bottom: 12px">
            <el-col :sm="24" :md="12" :lg="24">
              <el-card class="box-card" body-style="height:280px">
                <MmvTitle title="夜间服务费规则"></MmvTitle>
                <div class="card-item table-padding">

                  <el-col :span="20">

                    <el-form-item label="是否启用" prop="nightServiceFee">
                      <el-radio-group v-model="form.tenantConfig.nightServiceFee" size="medium">
                        <el-radio :label="1">开启</el-radio>
                        <el-radio :label="2">关闭</el-radio>
                      </el-radio-group>
                    </el-form-item>
                  </el-col>
                  <el-col :span="12">
                    <el-form-item label="时间范围" prop="nightServiceFeePrice" class="feeExplain">
                      <el-time-picker
                        style="width: 150px"
                        placeholder="起始时间"
                        format="HH:mm"
                        value-format="HH:mm:00"
                        :disabled="form.tenantConfig.nightServiceFee == 2"
                        v-model="form.tenantConfig.nightServiceFeeStart">
                      </el-time-picker>
                      至

                      <el-time-picker
                        style="width: 150px"
                        placeholder="结束时间"
                        format="HH:mm"
                        value-format="HH:mm:00"
                        :disabled="form.tenantConfig.nightServiceFee == 2"
                        v-model="form.tenantConfig.nightServiceFeeEnd">
                      </el-time-picker>
                    </el-form-item>

                  </el-col>
                  <el-col :span="12">
                    <el-form-item label="费用" prop="nightServiceFeePrice" class="feeExplain">
                      <el-input v-model="form.tenantConfig.nightServiceFeePrice"
                                :disabled="form.tenantConfig.nightServiceFee == 2" @keyup.native="
                  form.tenantConfig.nightServiceFeePrice = oninput(
                    form.tenantConfig.nightServiceFeePrice, 2 )
                "></el-input>
                      <span>元/次</span>
                    </el-form-item>
                  </el-col>
                  <el-col :span="20">
                    <el-form-item label="收费项说明" prop="nightServiceFeeRemark" class="feeExplain">
                      <el-input v-model.trim="form.tenantConfig.nightServiceFeeRemark"
                                :disabled="form.tenantConfig.nightServiceFee == 2" type="textarea" placeholder="请输入说明" :maxlength="40" show-word-limit :autosize="{minRows: 2, maxRows: 4}"></el-input>
                    </el-form-item>
                  </el-col>
                </div>
              </el-card>
            </el-col>
          </el-row>


          <el-row :gutter="20" style="margin-bottom: 12px">
            <el-col :span="24">
              <el-card class="box-card" body-style="min-height:240px">
                <MmvTitle title="取消规则"></MmvTitle>
                <el-row>
                  <el-col :md="24" class="col-padding">
                    <el-collapse accordion
                                 style="border: 1px solid rgb(242 242 242);text-align: left;border-radius: 4px; background-color: rgb(242 242 242);">
                      <el-collapse accordion
                                   style="
                                                                                                                            border: 1px solid rgb(242 242 242);
                                                                                                                            text-align: left;
                                                                                                                            border-radius: 4px;
                                                                                                                            background-color: rgb(242 242 242);
                                                                                                                          ">
                        <el-row style="padding: 10px 20px; box-sizing: boder-box">
                          <el-col :span="24" style="font-size: 18px">
                            <div
                              style="
                                                                                                                                  color: rgb(51 51 51);
                                                                                                                                  margin: 10px 10px;
                                                                                                                                  letter-space: 2px;
                                                                                                                                ">
                              <i class="el-icon-info"></i> 取消指南：
                            </div>
                          </el-col>
                          <el-col :span="24">
                            <div
                              style="
                                                                                                                                  color: rgb(163 155 155);
                                                                                                                                  line-height: 2em;
                                                                                                                                  text-indent: 4em;
                                                                                                                                  letter-space: 2px;
                                                                                                                                ">
                              系统根据商户自定义取消规则，会自动计算取消订单违约金扣款。数值为0时，默认为不扣除违约金
                            </div>
                            <div
                              style="
                                                                                                                                  color: rgb(66 63 63);
                                                                                                                                  line-height: 2em;
                                                                                                                                  text-indent: 4em;
                                                                                                                                  letter-space: 2px;
                                                                                                                                ">
                              设置后会在小程序订单确认页面展示
                            </div>
                          </el-col>
                        </el-row>
                      </el-collapse>
                    </el-collapse>
                  </el-col>
                  <el-col :md="24" class="col-padding">
                    <el-divider content-position="left" class="title-content">平日订单(含周末)
                    </el-divider>
                    <el-row>
                      <el-col :span="18">
                        <div class="card-item table-padding">
                          <span>距离取车时间</span>
                          <el-input v-model="form.ordinaryDays.freeDuration"
                                    @keyup.native="form.ordinaryDays.freeDuration = oninput(form.ordinaryDays.freeDuration, 0)"></el-input>
                          <span>小时(含)以上的，免费取消</span>
                        </div>

                        <div class="card-item table-padding" v-for="(item, index) in form.ordinaryDays.ruleItemList"
                             :key="item.id">
                          <span>距离取车时间</span>
                          <el-input v-model="item.ruleTime" @keyup.native="
                        item.ruleTime = oninput(item.ruleTime, 0)
                      "></el-input>
                          <span>小时以内的，将收取</span>
                          <el-select v-model="item.ruleBase">
                            <el-option :value="1" label="订单总额"></el-option>
                            <el-option :value="2" label="首日租金"></el-option>
                          </el-select>
                          <span>的</span>
                          <el-input v-model="item.ruleValue" @keyup.native="
                        item.ruleValue = oninput(item.ruleValue, 2)
                      "></el-input>
                          <span>% 为违约金</span>

                          <el-button style="margin-left: 10px" type="success" size="mini" @click="addOrdinary(item.ruleId)"
                                     v-if="index == 0">新增
                          </el-button>
                          <el-button style="margin-left: 10px" type="danger" size="mini" @click="delOrdinary(index)"
                                     v-if="index > 0">删除
                          </el-button>
                        </div>

                        <div class="card-item table-padding">
                          <span>过取车时间未取车 ，将收取</span>
                          <el-select v-model="form.ordinaryDays.overdueBase">
                            <el-option :value="1" label="订单总额"></el-option>
                            <el-option :value="2" label="首日租金"></el-option>
                          </el-select>
                          <span>的</span>
                          <el-input v-model="form.ordinaryDays.overdueRatio" @keyup.native="
                        form.ordinaryDays.overdueRatio = oninput(
                          form.ordinaryDays.overdueRatio,
                          2
                        )
                      "></el-input>
                          <span>% 为违约金</span>
                        </div>
                      </el-col>
                    </el-row>

                    <el-divider content-position="left" class="title-content">三~五天节假日订单
                    </el-divider>
                    <el-row>
                      <el-col :span="18">
                        <div class="card-item table-padding">
                          <span>距离取车时间</span>
                          <el-input v-model="form.shortHoliday.freeDuration" @keyup.native="
                        form.shortHoliday.freeDuration = oninput(
                          form.shortHoliday.freeDuration,
                          0
                        )
                      " :disabled="closeShortHoliday"></el-input>
                          <span>小时(含)以上的，免费取消</span>
                        </div>

                        <div class="card-item table-padding" v-for="(item, index) in form.shortHoliday.ruleItemList"
                             :key="item.id" :disabled="closeShortHoliday">
                          <span>距离取车时间</span>
                          <el-input v-model="item.ruleTime" @keyup.native="
                        item.ruleTime = oninput(item.ruleTime, 0)
                      " :disabled="closeShortHoliday"></el-input>
                          <span>小时以内的，将收取</span>
                          <el-select v-model="item.ruleBase" :disabled="closeShortHoliday">
                            <el-option :value="1" label="订单总额"></el-option>
                            <el-option :value="2" label="首日租金"></el-option>
                          </el-select>
                          <span>的</span>
                          <el-input v-model="item.ruleValue" @keyup.native="
                        item.ruleValue = oninput(item.ruleValue, 2)
                      " :disabled="closeShortHoliday"></el-input>
                          <span>% 为违约金</span>
                          <el-button style="margin-left: 10px" v-show="!closeShortHoliday" type="success" size="mini"
                                     @click="addShortHoliday(item.ruleId)" v-if="index == 0">新增
                          </el-button>
                          <el-button style="margin-left: 10px" v-show="!closeShortHoliday" type="danger" size="mini"
                                     @click="delShortHoliday(index)" v-if="index > 0">删除
                          </el-button>
                        </div>

                        <div class="card-item table-padding">
                          <span>过取车时间未取车 ，将收取</span>
                          <el-select v-model="form.shortHoliday.overdueBase" :disabled="closeShortHoliday">
                            <el-option :value="1" label="订单总额"></el-option>
                            <el-option :value="2" label="首日租金"></el-option>
                          </el-select>
                          <span>的</span>
                          <el-input v-model="form.shortHoliday.overdueRatio" @keyup.native="
                        form.shortHoliday.overdueRatio = oninput(
                          form.shortHoliday.overdueRatio,
                          2
                        )
                      " :disabled="closeShortHoliday"></el-input>
                          <span>% 为违约金</span>
                        </div>
                      </el-col>
                      <el-col :span="6">
                        <el-switch v-model="form.shortHoliday.ruleStatus" active-text="开启" :active-value="1"
                                   inactive-text="关闭" :inactive-value="2" @change="changeShortHoliday">
                        </el-switch>
                      </el-col>
                    </el-row>

                    <el-divider content-position="left" class="title-content">七天节假日订单
                    </el-divider>
                    <el-row>
                      <el-col :span="18">
                        <div class="card-item table-padding">
                          <span>距离取车时间</span>
                          <el-input v-model="form.longHoliday.freeDuration" @keyup.native="
                        form.longHoliday.freeDuration = oninput(
                          form.longHoliday.freeDuration,
                          0
                        )
                      " :disabled="closeLongHoliday"></el-input>
                          <span>小时(含)以上的，免费取消</span>
                        </div>

                        <div class="card-item table-padding" v-for="(item, index) in form.longHoliday.ruleItemList"
                             :key="item.id">
                          <span>距离取车时间</span>
                          <el-input v-model="item.ruleTime" @keyup.native="
                        item.ruleTime = oninput(item.ruleTime, 0)
                      " :disabled="closeLongHoliday"></el-input>
                          <span>小时以内的，将收取</span>
                          <el-select v-model="item.ruleBase" :disabled="closeLongHoliday">
                            <el-option :value="1" label="订单总额"></el-option>
                            <el-option :value="2" label="首日租金"></el-option>
                          </el-select>
                          <span>的</span>
                          <el-input v-model="item.ruleValue" @keyup.native="
                        item.ruleValue = oninput(item.ruleValue, 2)
                      " :disabled="closeLongHoliday"></el-input>
                          <span>% 为违约金</span>

                          <el-button style="margin-left: 10px" v-show="!closeLongHoliday" type="success" size="mini"
                                     @click="addLongHoliday(item.ruleId)" v-if="index == 0">新增
                          </el-button>
                          <el-button style="margin-left: 10px" v-show="!closeLongHoliday" type="danger" size="mini"
                                     @click="delLongHoliday(index)" v-if="index > 0">删除
                          </el-button>
                        </div>

                        <div class="card-item table-padding">
                          <span>过取车时间未取车 ，将收取</span>
                          <el-select v-model="form.longHoliday.overdueBase" :disabled="closeLongHoliday">
                            <el-option :value="1" label="订单总额"></el-option>
                            <el-option :value="2" label="首日租金"></el-option>
                          </el-select>
                          <span>的</span>
                          <el-input v-model="form.longHoliday.overdueRatio" @keyup.native="
                        form.longHoliday.overdueRatio = oninput(
                          form.longHoliday.overdueRatio,
                          2
                        )
                      " :disabled="closeLongHoliday"></el-input>
                          <span>% 为违约金</span>
                        </div>
                      </el-col>
                      <el-col :span="6">
                        <el-switch v-model="form.longHoliday.ruleStatus" active-text="开启" :active-value="1" inactive-text="关闭"
                                   :inactive-value="2" @change="changeOrdinary">
                        </el-switch>
                      </el-col>
                    </el-row>
                  </el-col>
                </el-row>
              </el-card>
            </el-col>
          </el-row>
          <el-row style="margin-bottom: 12px">
            <el-col :span="24">
              <el-card class="box-card" body-style="min-height:350px">
                <MmvTitle title="提前退车规则"></MmvTitle>
                <div class="table-padding">
                  <el-collapse accordion style="
                                                                                                                        border: 1px solid rgb(242 242 242);
                                                                                                                        text-align: left;
                                                                                                                        border-radius: 4px;
                                                                                                                        background-color: rgb(242 242 242);
                                                                                                                      ">
                    <el-collapse accordion
                                 style="
                                                                                                                          border: 1px solid rgb(242 242 242);
                                                                                                                          text-align: left;
                                                                                                                          border-radius: 4px;
                                                                                                                          background-color: rgb(242 242 242);
                                                                                                                        ">
                      <el-row style="padding: 10px 20px; box-sizing: boder-box">
                        <el-col :span="24" style="font-size: 18px">
                          <div
                            style="
                                                                                                                                color: rgb(51 51 51);
                                                                                                                                margin: 10px 10px;
                                                                                                                                letter-space: 2px;
                                                                                                                              ">
                            <i class="el-icon-info"></i> 退单指南：
                          </div>
                        </el-col>
                        <el-col :span="24">
                          <div
                            style="
                                                                                                                                color: rgb(163 155 155);
                                                                                                                                line-height: 2em;
                                                                                                                                text-indent: 4em;
                                                                                                                                letter-space: 2px;
                                                                                                                              ">
                            系统根据商户自定义退车规则，会自动计算订单提前退车扣款。
                          </div>
                          <div
                            style="
                                                                                                                                color: rgb(66 63 63);
                                                                                                                                line-height: 2em;
                                                                                                                                text-indent: 4em;
                                                                                                                                letter-space: 2px;
                                                                                                                              ">
                            设置后会在小程序订单确认页面展示，订单页面不展示提前退车按钮，如需提前退车，需要客户联系门店协商在后台操作
                          </div>
                        </el-col>
                      </el-row>
                    </el-collapse>
                  </el-collapse>
                  <div class="col-d">
                    <div class="col-l">
                      1.提前联系门店，如需提前还车，请在还车前2小时联系门店，在门店营业时间范围内办理还车手续，如未提前联系，可能导致无法及时还车
                      如在夜间时间段办理还车手续，请在下单前后咨询门店，夜间情况特殊可能无人办理
                    </div>
                    <div class="col-l">2.节假日提前还车不退还剩余租金</div>
                    <div class="col-l">
                      <span>普通日提前还车，用车当日按整天计费，剩余日期租金的</span>
                      <el-input v-model="form.advanceCartRules" @keyup.native="
                    form.advanceCartRules = oninput(form.advanceCartRules, 2)
                  "></el-input>
                      <span>% 要作为退车违约金</span>
                    </div>
                  </div>
                </div>
              </el-card>
            </el-col>
          </el-row>

          <el-row :gutter="20" style="margin-bottom: 12px">
            <el-col :span="24">
              <el-card class="box-card" body-style="min-height:240px">
                <MmvTitle title="赔付规则"></MmvTitle>
                <div class="table-padding">
                  <el-collapse accordion style="
                                                                                                                        border: 1px solid rgb(242 242 242);
                                                                                                                        text-align: left;
                                                                                                                        border-radius: 4px;
                                                                                                                        background-color: rgb(242 242 242);
                                                                                                                      ">
                    <el-collapse accordion
                                 style="
                                                                                                                          border: 1px solid rgb(242 242 242);
                                                                                                                          text-align: left;
                                                                                                                          border-radius: 4px;
                                                                                                                          background-color: rgb(242 242 242);
                                                                                                                        ">
                      <el-row style="padding: 10px 20px; box-sizing: boder-box">
                        <el-col :span="24" style="font-size: 18px">
                          <div
                            style="
                                                                                                                                color: rgb(51 51 51);
                                                                                                                                margin: 10px 10px;
                                                                                                                                letter-space: 2px;
                                                                                                                              ">
                            <i class="el-icon-info"></i> 赔付指南：
                          </div>
                        </el-col>
                        <el-col :span="24">
                          <div
                            style="
                                                                                                                                color: rgb(163 155 155);
                                                                                                                                line-height: 2em;
                                                                                                                                text-indent: 4em;
                                                                                                                                letter-space: 2px;
                                                                                                                              ">
                            提醒客户在租赁时出现车损，会根据不同级别车辆的大约赔付标准。
                          </div>
                          <div
                            style="
                                                                                                                                color: rgb(66 63 63);
                                                                                                                                line-height: 2em;
                                                                                                                                text-indent: 4em;
                                                                                                                                letter-space: 2px;
                                                                                                                              ">
                            设置后会在小程序订单确认页面展示。
                          </div>
                        </el-col>
                      </el-row>
                    </el-collapse>
                  </el-collapse>
                </div>
                <div class="table-padding">
                  <el-row class="col-d">
                    <el-col :span="24" class="col-l"> 维修费公示:</el-col>
                  </el-row>
                  <div style="margin-left: 40px; line-height: 2em">
                    车辆小刮蹭(维修费≤5000元)
                  </div>
                  <div style="margin-left: 60px; line-height: 2em">
                    <div v-for="(data, index) in form.compensationRules" :key="index">
                      <div>
                        <dict-tag :options="dict.type.compensate_rule" style="color: red; display: inline-block"
                                  :value="data.ruleDict"/>
                        <el-input v-model="data.ruleValue" @keyup.native="
                      data.ruleValue = oninput(data.ruleValue, 2)
                    "></el-input>
                        <span style="color: red">元/漆面</span>
                      </div>
                    </div>
                    <el-row>
                      <el-col :span="24">
                        <label style="color: red">维修项目/标准面系数</label>
                      </el-col>
                      <el-col :span="24">
                        <label style="color: rgb(66 63 63)">*0.5个标准面:后视镜(左)、后视镜(右)</label>
                      </el-col>
                      <el-col :span="24">
                        <label
                          style="color: rgb(66 63 63)">*1.0个标准面:保险杠(前)、保险杠(后)、叶子板左)、叶子板(右)、车门(前)、车门(后)、裙边(左)、裙边(右)、A柱(左)、A柱(右)、C柱(左)、C柱(右)、车轮钢圈(个)</label>
                      </el-col>
                      <el-col :span="24">
                        <label style="color: rgb(66 63 63)">*1.5个标准面:前机盖、后盖、车顶</label>
                      </el-col>
                    </el-row>
                  </div>
                  <div style="margin-left: 40px; line-height: 2em">
                    车辆非小刮蹭(维修费>5000元)
                  </div>
                  <el-row style="margin-left: 60px; line-height: 2em">
                    <el-col :span="24">
                      <label style="color: red">依据4S店定损后维修金额为准</label>
                    </el-col>
                    <el-col :span="24">
                      <label style="color: rgb(66 63 63)">x 以下情况无法提供保障服务:</label>
                    </el-col>
                    <el-col :span="24">
                      <label style="color: rgb(66 63 63)">x 发生事故未立即通知租赁公司或电报保险</label>
                    </el-col>
                    <el-col :span="24">
                      <label style="color: rgb(66 63 63)">x 无事故证明材料或无保险报案理赔材料</label>
                    </el-col>
                    <el-col :span="24">
                      <label style="color: rgb(66 63 63)">x
                        无证驾驶、酒驾、毒驾、危险驾驶等其它保险公司不予理赔的部分</label>
                    </el-col>
                  </el-row>
                </div>
              </el-card>
            </el-col>
          </el-row>

        </el-form>

      </el-tab-pane>

      <el-tab-pane label="车辆配置" name="second">

        <el-form size="medium" label-width="100px">
          <el-row :gutter="20" style="margin-bottom: 12px">
            <el-col :sm="24" :md="12" :lg="10">
              <el-card class="box-card" body-style="height:220px">
                <MmvTitle title="预留车辆整备时间"></MmvTitle>
                <div class="card-item table-padding">
                  <el-form-item label="车辆整备" prop="isVehicleServicing">
                    <el-radio-group v-model="form.tenantConfig.isVehicleServicing" size="medium">
                      <el-radio :label="1">开启</el-radio>
                      <el-radio :label="2">关闭</el-radio>
                    </el-radio-group>
                  </el-form-item>
                  <el-form-item label="预留整备时间" prop="vehicleServicingDuration">
                    <el-input v-model="form.tenantConfig.vehicleServicingDuration" placeholder="请输入" clearable
                              :style="{ 'min-width': '200px' }"
                              oninput="if(!/^[1-9]+$/.test(value)) value=value.replace(/\D/g,'');if(value>48)value=48;if(value<1)value=null">
                      <template slot="append">小时</template>
                    </el-input>
                  </el-form-item>
                </div>
              </el-card>
            </el-col>
            <el-col :sm="24" :md="12" :lg="14">
              <el-card class="box-card" body-style="height:220px">
                <MmvTitle title="维保提醒设置"></MmvTitle>
                <div class="card-item table-padding">
                  近
                  <el-input v-model="form.tenantConfig.insuranceDay" @keyup.native="
                form.tenantConfig.insuranceDay = oninput(
                  form.tenantConfig.insuranceDay,
                  0
                )
              "></el-input>
                  天（含）以上的交强险到期提醒
                </div>
                <div class="card-item table-padding">
                  近
                  <el-input v-model="form.tenantConfig.maintenanceDay" @keyup.native="
                form.tenantConfig.maintenanceDay = oninput(
                  form.tenantConfig.maintenanceDay,
                  0
                )
              "></el-input>
                  天（含）以上的商业险到期提醒
                </div>
                <div class="card-item table-padding">
                  近
                  <el-input v-model="form.tenantConfig.inspectionDay" @keyup.native="
                form.tenantConfig.inspectionDay = oninput(
                  form.tenantConfig.inspectionDay,
                  0
                )
              "></el-input>
                  天（含）以上的年检到期提醒
                </div>
              </el-card>
            </el-col>
<!--            <el-col :sm="24" :md="12" :lg="8">-->
<!--              <el-card class="box-card" body-style="height:220px">-->
<!--                <MmvTitle title="车辆租满是否继续出租"></MmvTitle>-->
<!--                <div class="card-item table-padding">-->

<!--                  <div class="card-title-info">开启后，车型订单达到车辆库存后，客户将无法下单</div>-->
<!--                  <el-form-item style="margin: 20px 0" label="选择" prop="stockLimit">-->
<!--                    <el-radio-group v-model="form.tenantConfig.stockLimit" size="medium">-->
<!--                      <el-radio :label="2">继续出租</el-radio>-->
<!--                      <el-radio :label="1">不出租</el-radio>-->
<!--                    </el-radio-group>-->
<!--                  </el-form-item>-->
<!--                </div>-->
<!--              </el-card>-->
<!--            </el-col>-->
          </el-row>
          <el-row :gutter="20" style="margin-bottom: 12px">
            <el-col :sm="24">
              <el-card class="box-card">
                <MmvTitle title="车辆违章配置"></MmvTitle>
                <el-form ref="illegalform" :model="form.violationWarning" :rules="rules">
                  <el-row :gutter="20">
                    <el-col :span="10">
                      <el-card body-style="height:320px">
                        <el-row justify="space-between">
                          <el-col :span="16"><span class="medium-title">自动查询车辆违章</span></el-col>
                          <el-col :span="8">
                            <el-form-item label="" prop="automaticPolling" style="margin-top: -5px;">
                              <el-switch v-model="form.violationWarning.automaticEnable" active-text="开启" :active-value="1"
                                         inactive-text="关闭" :inactive-value="0">
                              </el-switch>
                            </el-form-item>
                          </el-col>
                        </el-row>
                        <el-row>

                          <el-form-item label="" prop="automaticPolling">
                            <div>
                              <span>每隔</span>
                              <el-input v-model="form.violationWarning.automaticPolling"
                                        :disabled="form.violationWarning.automaticEnable == 0"
                                        @keyup.native="form.violationWarning.automaticPolling = oninput(form.violationWarning.automaticPolling, 0, 100)"></el-input>
                              <span>天，自动查询交管平台违章信息</span>
                            </div>
                          </el-form-item>

                          <el-form-item label="开始查询时间:" prop="queryStartDate">
                            <div>
                              <el-date-picker style="width: auto" v-model="form.violationWarning.queryStartDate"
                                              :picker-options="pickerOptions" type="date" placeholder="选择开始查询日期" size="large"
                                              value-format="yyyy-MM-dd" :disabled="
                              form.violationWarning.automaticEnable == 0
                            ">
                              </el-date-picker>
                            </div>
                          </el-form-item>

                          <el-form-item label="查询车辆:" prop="queryReturnCarDay">
                            <div>
                              <el-radio-group size="medium" v-model="form.violationWarning.queryMode">
                                <el-radio :label="0" :disabled="
                              form.violationWarning.automaticEnable == 0
                            ">全部车辆
                                </el-radio>
                                <el-radio :label="1" :disabled="
                              form.violationWarning.automaticEnable == 0
                            ">
                                  <span>订单还车达</span>
                                  <el-input :disabled="
                                form.violationWarning.automaticEnable == 0
                              " v-model="form.violationWarning.queryReturnCarDay"></el-input>
                                  <span>天的车辆</span>
                                </el-radio>
                              </el-radio-group>
                            </div>

                          </el-form-item>


                        </el-row>
                      </el-card>
                    </el-col>


                    <el-col :span="14">
                      <el-card body-style="height:320px">
                        <el-row>
                          <div class="medium-title">车辆违章预警</div>
                        </el-row>
                        <el-row style="margin-top: 20px;">
                          <el-form-item label="" prop="warningSett">
                            <el-select v-model="form.violationWarning.warningSett" placeholder="请选择" >
                              <el-option  label="满足所有条件" :value="1" ></el-option>
                              <el-option  label="满足任意条件" :value="2"></el-option>
                            </el-select>
                          </el-form-item>
                        </el-row>
                        <el-row>
                          <el-form-item label="" prop="earlyNumber">
                            <div style="margin-top: 5px">
                              <span>车辆未处理违章次数达</span>
                              <el-input v-model="form.violationWarning.earlyNumber"
                                        :disabled="form.violationWarning.numberEnable == 0"
                                        @keyup.native="form.violationWarning.earlyNumber = oninput(form.violationWarning.earlyNumber, 0, 100)"></el-input>
                              <span style="margin-right:113px">次，登录系统后自动提醒</span>

                              <el-switch v-model="form.violationWarning.numberEnable" active-text="开启" :active-value="1"
                                         inactive-text="关闭" :inactive-value="0">
                              </el-switch>
                            </div>
                          </el-form-item>
                        </el-row>

                        <el-row>
                          <el-form-item label="" prop="earlyMoney">
                            <div style="margin-top: 5px">
                              <span>车辆未处理违章罚款达</span>
                              <el-input v-model="form.violationWarning.earlyMoney"
                                        :disabled="form.violationWarning.moneyEnable == 0"
                                        @keyup.native="form.violationWarning.earlyMoney = oninput(form.violationWarning.earlyMoney, 0)"></el-input>
                              <span style="margin-right:113px">元，登录系统后自动提醒</span>

                              <el-switch v-model="form.violationWarning.moneyEnable" active-text="开启" :active-value="1"
                                         inactive-text="关闭" :inactive-value="0">
                              </el-switch>
                            </div>
                          </el-form-item>
                        </el-row>

                        <el-row>
                          <el-form-item label="" prop="earlyScore">
                            <div style="margin-top: 5px">
                              <span>车辆未处理违章分数达</span>
                              <el-input v-model="form.violationWarning.earlyScore"
                                        :disabled="form.violationWarning.scoreEnable == 0"
                                        @keyup.native="form.violationWarning.earlyScore = oninput(form.violationWarning.earlyScore, 0, 100)"></el-input>
                              <span style="margin-right:113px">分，登录系统后自动提醒</span>

                              <el-switch v-model="form.violationWarning.scoreEnable" active-text="开启" :active-value="1"
                                         inactive-text="关闭" :inactive-value="0">
                              </el-switch>
                            </div>
                          </el-form-item>
                        </el-row>
                      </el-card>
                    </el-col>
                  </el-row>

                </el-form>
              </el-card>
            </el-col>
          </el-row>
        </el-form>

      </el-tab-pane>


      <el-tab-pane label="其他配置" name="fourth">
        <el-form size="medium" label-width="100px" label-position="left">
          <el-row :gutter="20" style="margin-bottom: 12px">
            <el-col :sm="24" :md="12" :lg="8">
              <el-card class="box-card" body-style="height:180px">
                <MmvTitle title="GPS设备告警"></MmvTitle>
                <div class="card-item table-padding">
                  <el-form-item label="声音提醒" prop="isVehicleServicing">
                    <el-radio-group v-model="form.tenantConfig.gpsAlarmSound" size="medium">
                      <el-radio :label="1">开启</el-radio>
                      <el-radio :label="2">关闭</el-radio>
                    </el-radio-group>
                  </el-form-item>
                </div>
              </el-card>
            </el-col>
            <el-col :sm="24" :md="12" :lg="8">
              <el-card class="box-card" body-style="height:180px">
                <MmvTitle title="返佣规则"></MmvTitle>
                <div class="card-item table-padding">
                  <el-form-item label="一级佣金" prop="primaryAmountChecked">
                    <el-row>
                      <el-select v-model="form.commissionPlan.primaryAmountChecked" @change="primaryAmount">
                        <el-option label="按固定金额" :value="1"></el-option>
                        <el-option label="按百分比" :value="2"></el-option>
                      </el-select>
                      <!-- 按固定金额 -->
                      <el-input v-if="form.commissionPlan.primaryAmountChecked == 1"
                                v-model="form.commissionPlan.primaryCommissionAmount" style="margin-left: 6px"
                                title="一级分销佣金金额（最多两位小数）" placeholder="分销佣金金额" @keyup.native="
                      form.commissionPlan.primaryCommissionAmount = oninput(
                        form.commissionPlan.primaryCommissionAmount,
                        2
                      )
                    ">
                        <div slot="suffix" style="margin-right: 8px">元</div>
                      </el-input>
                      <!-- 按百分比 -->
                      <el-input v-else v-model="form.commissionPlan.primaryCommissionPercentage" style="margin-left: 6px"
                                title="一级分销佣金百分比（最多两位小数）" placeholder="分销佣金百分比" @keyup.native="
                      form.commissionPlan.primaryCommissionPercentage = oninput(
                        form.commissionPlan.primaryCommissionPercentage,
                        2
                      )
                    ">
                        <div slot="suffix" style="margin-right: 8px">%</div>
                      </el-input>
                    </el-row>
                  </el-form-item>
                  <el-form-item label="二级佣金" prop="secondaryAmountChecked">
                    <el-row>
                      <el-select v-model="form.commissionPlan.secondaryAmountChecked" @change="secondaryAmount">
                        <el-option label="按固定金额" :value="1"></el-option>
                        <el-option label="按百分比" :value="2"></el-option>
                      </el-select>
                      <!-- 按固定金额 -->
                      <el-input v-if="form.commissionPlan.secondaryAmountChecked == 1"
                                v-model="form.commissionPlan.secondaryCommissionAmount" placeholder="分销佣金金额" title="二级分销佣金金额（最多两位小数）"
                                style="margin-left: 6px" @keyup.native="
                      form.commissionPlan.secondaryCommissionAmount = oninput(
                        form.commissionPlan.secondaryCommissionAmount,
                        2
                      )
                    ">
                        <div slot="suffix" style="margin-right: 8px">元</div>
                      </el-input>
                      <el-input v-else v-model="form.commissionPlan.secondaryCommissionPercentage" style="margin-left: 6px"
                                title="二级分销佣金百分比（最多两位小数）" placeholder="分销佣金百分比" @keyup.native="
                      form.commissionPlan.secondaryCommissionPercentage =
                      oninput(
                        form.commissionPlan.secondaryCommissionPercentage,
                        2
                      )
                    ">
                        <div slot="suffix" style="margin-right: 8px">%</div>
                      </el-input>
                    </el-row>
                  </el-form-item>
                </div>
              </el-card>
            </el-col>
            <el-col :sm="24" :md="12" :lg="8">
              <el-card class="box-card" body-style="height:180px">
                <MmvTitle title="财务审核"></MmvTitle>
                <div class="card-item table-padding">
                  <el-form-item label="财务确认收款" prop="financialConfirmCollection">
                    <el-radio-group v-model="form.tenantConfig.financialConfirmCollection" size="medium">
                      <el-radio :label="1">开启</el-radio>
                      <el-radio :label="2">关闭</el-radio>
                    </el-radio-group>
                  </el-form-item>
                  <el-form-item label="财务确认退款" prop="financeConfirmsRefund">
                    <el-radio-group v-model="form.tenantConfig.financeConfirmsRefund" size="medium">
                      <el-radio :label="1">开启</el-radio>
                      <el-radio :label="2">关闭</el-radio>
                    </el-radio-group>
                  </el-form-item>
                </div>
              </el-card>
            </el-col>
          </el-row>

          <el-row :gutter="20" style="margin-bottom: 12px">
            <el-col :sm="24">
              <el-card class="box-card">
                <MmvTitle title="下单设置"></MmvTitle>
                <el-row :gutter="20">
                  <el-col :span="8">
                    <el-card class="box-card"   body-style="height:260px">
                      <el-row>
                        <span class="medium-title">下单认证</span>
                      </el-row>
                      <div class="card-item table-padding"  style="margin: 20px 0" >
                        <div class="card-title-info">开启后，客户需实名认证后才可以下单</div>
                        <el-radio-group v-model="form.tenantConfig.certificationOrder" size="medium">
                          <el-radio :label="1">开启</el-radio>
                          <el-radio :label="2">关闭</el-radio>
                        </el-radio-group>
                      </div>
                      <el-row> <span class="medium-title">重复下单</span></el-row>
                      <div class="card-item table-padding"  style="margin: 20px 0" >
                        <div class="card-title-info">开启后，客户可以在同一用车时间多次下单</div>
                        <el-radio-group v-model="form.tenantConfig.onlyRunOrder" size="medium">
                          <el-radio :label="1">开启</el-radio>
                          <el-radio :label="2">关闭</el-radio>
                        </el-radio-group>
                      </div>
                    </el-card>
                  </el-col>

                  <el-col :span="8">
                    <el-card class="box-card"   body-style="height:260px">

                      <el-row> <span class="medium-title">门店服务范围外下单</span></el-row>
                      <div class="card-item table-padding"  style="margin: 20px 0" >
                        <div class="card-title-info" style="position: relative;left: -6px">允许后，选择上门送取车位置超出门店服务范围，可以下单</div>
                        <div style="display: flex;justify-content: space-between;position: relative;left: -25px">
                          <el-form-item label="客户端下单" prop="financeConfirmsRefund">
                            <el-switch
                              class="my-rule-switch"
                              v-model="form.tenantConfig.outOfRange"
                              :active-value="1"
                              :inactive-value="2"
                              active-text="允许"
                              inactive-text="禁止"
                            >
                            </el-switch>
                          </el-form-item>

                          <el-form-item label="代客下单" prop="financeConfirmsRefund">
                            <el-switch
                              class="my-rule-switch"
                              v-model="form.tenantConfig.outOfRangeAdmin"
                              :active-value="1"
                              :inactive-value="2"
                              active-text="允许"
                              inactive-text="禁止">
                            </el-switch>
                          </el-form-item>
                        </div>
                      </div>

                      <el-row> <span class="medium-title">门店服务时间外下单</span></el-row>
                      <div class="card-item table-padding"  style="margin: 20px 0" >
                        <div class="card-title-info" style="position: relative;left: -6px">允许后，选择预约取还车时间在门店服务时间外，可以下单</div>
                        <div style="display: flex;justify-content: space-between;position: relative;left: -25px">
                          <el-form-item label="客户端下单" prop="outOfTime">
                            <el-switch
                              class="my-rule-switch"
                              v-model="form.tenantConfig.outOfTime"
                              :active-value="1"
                              :inactive-value="2"
                              active-text="允许"
                              inactive-text="禁止">
                            </el-switch>
                          </el-form-item>

                          <el-form-item label="代客下单" prop="outOfTimeAdmin">
                            <el-switch
                              class="my-rule-switch"
                              v-model="form.tenantConfig.outOfTimeAdmin"
                              :active-value="1"
                              :inactive-value="2"
                              active-text="允许"
                              inactive-text="禁止">
                            </el-switch>
                          </el-form-item>
                        </div>
                      </div>

                    </el-card>
                  </el-col>

                  <el-col :span="8">
                    <el-card class="box-card"  body-style="height:260px">
                      <el-row> <span class="medium-title">车辆租满是否继续出租</span></el-row>
                      <div class="card-item table-padding"  style="margin: 20px 0" >
                        <div class="card-title-info">车型订单达到车辆库存后，是否继续出租</div>
                        <el-radio-group v-model="form.tenantConfig.stockLimit" size="medium">
                          <el-radio :label="2">继续出租</el-radio>
                          <el-radio :label="1">不出租</el-radio>
                        </el-radio-group>
                      </div>
                      <el-row> <span class="medium-title">订单风控</span></el-row>
                      <div class="card-item table-padding"  style="margin: 20px 0" >
                        <div class="card-title-info">交车前是否必须查询反欺诈和签署电子合同</div>
                        <el-radio-group v-model="form.tenantConfig.preDeliveryInspection" size="medium">
                          <el-radio :label="1">是</el-radio>
                          <el-radio :label="2">否</el-radio>
                        </el-radio-group>
                      </div>
                    </el-card>
                  </el-col>

                </el-row>
              </el-card>
            </el-col>
          </el-row>



          <el-row :gutter="20" style="margin-bottom: 12px">
            <el-col :sm="24" :md="12" :lg="8"  v-if="electronicContractEnable===1">
              <el-card class="box-card" body-style="height:280px">
                <MmvTitle title="电子合同配置"></MmvTitle>
                <div class="card-item table-padding">

                  <el-form-item label="承租方签署方式" prop="quickSignature" label-width="140px">
                    <template v-slot:label>
                      <el-tooltip placement="right">
                        <div slot="content">
                          快捷签署：出租方发起电子合同后，客户可一步完成电子合同认证及签署<br/><br/>
                          正常签署：需客户完成电子合同认证后，出租方才可发起电子合同
                        </div>
                        <el-button style="color: #606268;font-weight: 700;font-size: 14px; position: relative;left: -20px" type="text">承租方签署方式&nbsp;<i class="el-icon-warning-outline"></i></el-button>
                      </el-tooltip>
                    </template>
                      <el-radio-group v-model="form.electronicContractConfig.quickSignature" size="medium">
                        <el-radio :label="1">快捷签署</el-radio>
                        <el-radio :label="2">正常签署</el-radio>
                      </el-radio-group>
                  </el-form-item>
                  <el-form-item label="签署顺序" prop="signOrder" label-width="120px">
                    <el-radio-group v-model="form.electronicContractConfig.signOrder" size="medium">
                      <el-radio :label="1">出租方先签署</el-radio>
                      <el-radio :label="2">承租方先签署</el-radio>
                    </el-radio-group>
                  </el-form-item>
                  <div>
                    <el-row> <span class="medium-title">承租方认证方式</span></el-row>
                    <div class="card-title-info" style="margin-top: 10px;">身份证核验:允许后,在核验身份信息的时候需要上传身份证</div>
                    <el-form-item label="是否上传身份证" prop="personalAuthenticationMethod" label-width="120px">
                      <el-radio-group v-model="form.electronicContractConfig.personalAuthenticationMethod" size="medium">
                        <el-radio :label="1">是</el-radio>
                        <el-radio :label="2">否</el-radio>
                      </el-radio-group>
                    </el-form-item>
                  </div>

                </div>
              </el-card>
            </el-col>
            <el-col :sm="24" :md="12" :lg="8">
              <el-card class="box-card" body-style="height:280px">
                <MmvTitle title="托管结算配置"></MmvTitle>
                <div class="card-item table-padding">
                  <el-form-item label="托管结算方式" prop="escrowSettlementType">
                    <el-radio-group v-model="form.tenantConfig.escrowSettlementType" size="medium">
                      <el-radio :label="1">线下结算</el-radio>
                      <el-radio :label="2">线上自动结算</el-radio>
                    </el-radio-group>
                  </el-form-item>
                </div>
              </el-card>
            </el-col>
            <el-col :sm="24" :md="12" :lg="8">
              <el-card class="box-card"  body-style="height:280px">

              </el-card>
            </el-col>
          </el-row>


        </el-form>

      </el-tab-pane>

    </el-tabs>

    <el-form size="medium" label-width="100px">

      <el-form-item style="position: fixed; bottom: 30px; right: 70px">
        <el-button type="" @click="getList" :loading="loading">刷新</el-button>
        <el-button type="primary" @click="submitForm" :loading="loading">
          保存
        </el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
import {
  getRule,
  updateRule,
  getTenantConfig,
  updateIllegalDeposit,
} from "@/api/system/rule";
import moment from "moment"
import MmvTitle from "@/components/MmvUI/MmvTitle.vue";
import {illegalQueryPriceDetail} from "@/api/credit/credit"

export default {
  components: {
    MmvTitle,
  },
  dicts: ["back_rule", "compensate_rule"],
  name: "Label",
  data() {
    return {
      electronicContractEnable:false,
      activeName: 'first',
      pickerOptions: {
        disabledDate(time) {
          // return time.getTime() > Date.now()//选当前时间之前的时间
          return time.getTime() < Date.now()//选当前时间之后的时间
        }
      },
      loading: false,
      commissionPlan: {},
      // 表单参数
      form: {
        advanceCartRules: 0,
        compensationRules: [],
        longHoliday: {},
        ordinaryDays: {},
        shortHoliday: {},
        tenantConfig: {},
        commissionPlan: {
          primaryAmountChecked: 1, // 一级分销佣金:1按固定金额、2按百分比
          primaryCommissionAmount: 0, // 一级分销佣金金额
          primaryCommissionPercentage: 0, // 一级分销佣金百分比
          secondaryAmountChecked: 1, // 二级分销佣金:1按固定金额、2按百分比
          secondaryCommissionAmount: 0, // 二级分销佣金金额
          secondaryCommissionPercentage: 0, // 	二级分销佣金百分比
        },
        violationWarning: {
          automaticEnable: 0, //自动查询车辆违章 是否启用 0未启用
          automaticPolling: 0, //自动查询车辆违章间隔 天
          numberEnable: 0, //违章次数预警 是否启用 0未启用，1启用
          earlyNumber: 0, //违章次数预警值
          moneyEnable: 0, //违章罚款预警 是否启用 0未启用，1启用
          earlyMoney: 0, //违章罚款预警值
          scoreEnable: 0,
          earlyScore: 0,
          warningSett: 1,
        },
        electronicContractConfig:{
          signOrder:1,//签署顺序:1出租方先签署，2承租方先签署
          quickSignature:2,//签署方式:1.快捷签署，2.正常签署（需客户认证)
          personalAuthenticationMethod:1//个人客户认证方式:1身份证核验，2人脸识别
        }
      },
      rules: {
        automaticPolling: [
          {
            pattern: /^([1-9][0-9]{0,1}|100)$/,
            message: "请输入1-100的整数",
            trigger: "blur",
          },
        ],
        earlyNumber: [
          {
            pattern: /^([1-9][0-9]{0,1}|100)$/,
            message: "请输入1-100的整数",
            trigger: "blur",
          },
        ],
        earlyMoney: [
          {
            pattern: /^([0-9]|([1-9][0-9]*)|(([0]\.\d{0,2}|[1-9][0-9]*\.\d{0,2})))$/,
            message: "费用输入有误",
            trigger: "blur",
          },
        ],
        earlyScore: [
          {
            pattern: /^([1-9][0-9]{0,1}|100)$/,
            message: "请输入1-100的整数",
            trigger: "blur",
          },
        ],
        vehicleServicingDuration: [
          {
            pattern: /^([1-9][0-9]{0,1}|48)$/,
            message: "请输入1-48的整数",
            trigger: "blur",
          },
        ],
      },
      adList: [{value: "bj", label: "北京"},
        {value: "ah", label: "安徽"},
        {value: "fj", label: "福建"},
        {value: "gd", label: "广东"},
        {value: "gx", label: "广西"},
        {value: "cq", label: "重庆"},
        {value: "gz", label: "贵州"},
        {value: "gs", label: "甘肃"},
        {value: "he", label: "河北"},
        {value: "jl", label: "吉林"},
        {value: "hl", label: "黑龙江"},
        {value: "js", label: "江苏"},
        {value: "jx", label: "江西"},
        {value: "ha", label: "河南"},
        {value: "hb", label: "湖北"},
        {value: "hn", label: "湖南"},
        {value: "hi", label: "海南"},
        {value: "sx", label: "山西"},
        {value: "nm", label: "内蒙古"},
        {value: "ln", label: "辽宁"},
        {value: "sh", label: "上海"},
        {value: "sd", label: "山东"},
        {value: "sc", label: "四川"},
        {value: "sn", label: "陕西"},
        {value: "qh", label: "青海"},
        {value: "nx", label: "宁夏"},
        {value: "tj", label: "天津"},
        {value: "zj", label: "浙江"},
        {value: "yn", label: "云南"},
        {value: "xz", label: "西藏"},
        {value: "xj", label: "新疆"}]
    };
  },
  computed: {
    closeShortHoliday: function () {
      return this.form.shortHoliday.ruleStatus == 2;
    },
    closeLongHoliday: function () {
      return this.form.longHoliday.ruleStatus == 2;
    },
  },
  mounted() {
    this.getList();
    this.zoom();
    // 窗口大小变化时，需要重算
    window.addEventListener("resize", this.zoom, false);
  },
  destroyed() {
    window.removeEventListener("resize", this.zoom, false);
  },
  methods: {
    zoom() {
      let domBodys = document.getElementsByClassName("box-card");
      for (const domBody of domBodys) {
        let num = document.body.clientWidth / 19;
        domBody.style.zoom = (num < 80 ? 80 : num) + "%";
      }
    },
    primaryAmount() {
      this.form.commissionPlan.primaryCommissionAmount = 0;
      this.form.commissionPlan.primaryCommissionPercentage = 0;
    },
    secondaryAmount() {
      this.form.commissionPlan.secondaryCommissionAmount = 0;
      this.form.commissionPlan.secondaryCommissionPercentage = 0;
    },
    addOrdinary(ruleId) {
      this.form.ordinaryDays.ruleItemList.push({
        backType: 3,
        id: Date.now(),
        ruleBase: null,
        ruleId: ruleId,
        ruleTime: 0,
        ruleValue: 0,
      });
    },
    delOrdinary(index) {
      this.form.ordinaryDays.ruleItemList.splice(index, 1);
    },
    changeOrdinary(val) {
      console.log(val);
      console.log(this.form.ordinaryDays.ruleStatus);
    },
    addShortHoliday(ruleId) {
      this.form.shortHoliday.ruleItemList.push({
        backType: 3,
        id: Date.now(),
        ruleBase: null,
        ruleId: ruleId,
        ruleTime: 0,
        ruleValue: 0,
      });
    },
    delShortHoliday(index) {
      this.form.shortHoliday.ruleItemList.splice(index, 1);
    },
    changeShortHoliday(val) {
      console.log(val);
      console.log(this.form.shortHoliday.ruleStatus);
    },
    addLongHoliday(ruleId) {
      this.form.longHoliday.ruleItemList.push({
        backType: 3,
        id: Date.now(),
        ruleBase: null,
        ruleId: ruleId,
        ruleTime: 0,
        ruleValue: 0,
      });
    },
    delLongHoliday(index) {
      this.form.longHoliday.ruleItemList.splice(index, 1);
    },
    changeLongHoliday(val) {
      console.log(val);
      console.log(this.form.longHoliday.ruleStatus);
    },
    /** 查询标签列表 */
    getList() {
      this.loading = true;
      getRule()
        .then((response) => {
          this.getElectronicContractEnable(response.data.tenantId);
          this.form = {
            advanceCartRules: response.data.advanceCartRules || 0,
            compensationRules: response.data.compensationRules || [],
            longHoliday: response.data.longHoliday || {},
            ordinaryDays: response.data.ordinaryDays || {},
            shortHoliday: response.data.shortHoliday || {},
            tenantConfig: response.data.tenantConfig || {},
            commissionPlan: response.data.commissionPlan,
            violationWarning: response.data.violationWarning,
            electronicContractConfig:response.data.electronicContractConfig||{}
          };
          if (this.form.violationWarning.queryStartDate == null) {
            this.form.violationWarning.queryStartDate = moment().format('YYYY-MM-DD');
          }
          if(this.form.violationWarning && !this.form.violationWarning.warningSett){
            this.form.violationWarning.warningSett=1;
          }
        })
        .finally(() => {
          this.loading = false;
        });
    },
   // 获取电子合同配置是否显示
   getElectronicContractEnable(tenantId){

      if (tenantId ===1 ){
        this.electronicContractEnable = 1;
      }else  {
        illegalQueryPriceDetail(tenantId).then(res=>{
          if(res.data){
            this.electronicContractEnable=res.data.electronicContractEnable;
          }
        })
      }


   },
    // 表单重置
    reset() {
      this.form = {
        advanceCartRules: 0,
        compensationRules: [],
        longHoliday: {},
        ordinaryDays: {},
        shortHoliday: {},
        tenantConfig: {},
      };
      this.resetForm("form");
    },

    validate() {
      // return new Promise((resolve) => {
      //   this.$refs["illegalform"].validate((valid) => {
      //     resolve(valid);
      //   });
      // });
      return true;
    },

    /** 提交按钮 */
    async submitForm() {
      const valid = await this.validate();
      if (valid) {
        this.loading = true;

        updateRule(this.form)
          .then((response) => {
            this.$modal.msgSuccess("修改成功");
            this.getList();
          })
          .finally(() => {
            this.loading = false;
          });
      }
    },
  },
};
</script>
<style scoped="scoped">
.col-padding {
  padding: 0 20px;
}

/deep/ .el-input__inner {
  height: 36px;
  line-height: 36px;
  border-color: rgb(26 132 179) !important;
  color: rgb(26 132 179);
}

/deep/ .el-input {
  width: 80px;
  margin: 0 10px;
}

/deep/ .el-select .el-input {
  width: 160px;
  margin: 0 10px;
}

/deep/ .illegalform .el-input {
  width: 200px !important;
  margin: 0 10px;
}

/deep/ .feeExplain .el-input {
  width: 200px !important;
  margin: 0 10px;
}

/deep/ .el-divider__text.is-left {
  font-size: 15px;
  font-weight: 700;
}

.table-padding {
  margin-bottom: 0px;
  padding: 0px 25px 10px;
}

.box-card {
  font-size: 15px;
}

.title-content {
  margin-bottom: 30px;
}

.col-d {
  margin: 16px;
}

.col-l {
  line-height: 2em;
}

.medium-title {
  font-size: 18px;
  color: #333;
  font-weight: bold;
}

/deep/ .el-form-item {
  margin-bottom: 10px !important;
}

.card-title-info {
  font-size: 12px;
  color: #999;
  margin: -10px 0 5px;
}

/deep/ .el-date-editor--daterange.el-input__inner {
  width: 200px;
  margin-left: 22px;
}
</style>
<style lang="scss">
.my-rule-switch {
  margin-left: -50px;
  .el-switch__label--left {
    position: relative;
    left: 85px;
    color: #fff;
    z-index: -1111;
    span {
      width: 40px;
    }
  }
  .el-switch__label--right {
    position: relative;
    right: 65px;
    color: #fff;
    z-index: -1111;
    span {
      display: inline-block;
      width: 40px;
    }
  }
  .el-switch__core {
    width: 65px !important;
  }
  .el-switch__label--right.is-active {
    z-index: 10;
    color: #fff !important;
  }
  .el-switch__label--left.is-active {
    z-index: 10;
    color: #fff !important;
  }
  .el-switch__core {
    height: 24px !important;
    border-radius: 12px !important;
  }
  .el-switch__core:after {
    top: 3px;
    left: 5px;
  }
  .el-switch.is-checked .el-switch__core::after {
    margin-left: -20px;
  }
}
</style>
